/// $Id$

#include "ace/Log_Msg.h"  // for logging messages

#include "tao/ORB_Core.h" // the ORB itself
#include "tao/RTCORBA/RTCORBA.h"  // all the RTCORBA capabilities

#include "DownSensorA.h" // our header

/// the main function. 
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      // as the very first thing, let us acquire the ORB using the bootstrap
      // process of ORB_init
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      // instantiate a tire sensor object
      DownSensorA *sensor = new DownSensorA (orb.in ());

      // parse the remaining arguments
      int result =
        sensor->parse_args (argc, argv);

      // check for errors
      if (result != 0) {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("main: parsing failed\n")));
        return 0;
      }

      // now initialize the sensor object
      if (sensor->init () == -1) {
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("main: sensor init failed\n")));
        return 0;
      }

      // now essentially hand over control to the ORB
      orb->run ();

    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught");
      return -1;
    }

  return 0;
}
